package xyz.showbooks.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xyz.dfm.pojo.User;
import xyz.showbooks.mapper.UserMapper;
import xyz.showbooks.service.UserService;

import java.util.List;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


//    public PageResult findUserById(PageResult pageResult) {
//        if(pageResult.getQuery() != null){
//            return pageResult
//                    .setRows(
//                        userMapper.findUserImgById(
//                            pageResult.getQuery()
//                            ,(pageResult.getPageNum()-1)*pageResult.getPageSize()
//                            ,pageResult.getPageSize()))
//                    .setTotal(userMapper.IdTotal(pageResult.getQuery()));
//        }return null;
//    }

    @Override
    public List<User> findUserByName(String name, Integer start, Integer pageSize) {
        System.out.println(name);
        System.out.println(start);
        System.out.println(pageSize);
        List<User> userByName = userMapper.findUserByName(name, start, pageSize);
        return userByName;
    }

    @Override
    public List<User> findUserByNumber(String number, Integer start, Integer size) {
        List<User> userByName = userMapper.findUserByNumber(number, start, size);
        return userByName;
    }

    @Override
    public List<User> findUserByStatus(String number, Integer start, Integer size) {
        List<User> userByName = userMapper.findUserByStatus(number, start, size);
        return userByName;
    }

    @Override
    public User findUserById(Integer userId) {
        return userMapper.findUserById(userId);
    }

    @Override
    public void updateUser(User user) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_Id", user.getUserId());
        userMapper.update(user, queryWrapper);
    }

}
